package org.dey.controller;

import org.dey.pojo.Exercise;
import org.dey.pojo.PageVo;
import org.dey.service.ExerciseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
public class ExerciseController {
    @Autowired
    ExerciseService exerciseService;

    @PostMapping("Exercise.action/{pageNum}/{pageSize}")
    public PageVo<Exercise> queryExercise(Exercise exercise,
                                          @PathVariable int pageNum,
                                          @PathVariable int pageSize) {

        PageVo<Exercise> queryuser = exerciseService.queryExercise(exercise, pageNum, pageSize);
        return queryuser;
    }

    //添加
    @PostMapping("addExercise.action")
    public int insertExercise(@RequestBody Exercise exercise) {

        return exerciseService.insertExercise(exercise);
    }

    @DeleteMapping("delExercise.action/{id}")
    public int deleteExercise(@PathVariable int id) {
        return exerciseService.deleteExercise(id);
    }

    @GetMapping("qureyExerciseById.action/{id}")
    public Exercise queryExerciseByid(@PathVariable int id) {
        return exerciseService.queryExerciseByid(id);
    }

    @PutMapping("xiugai.action")
    public int updateExercise(@RequestBody Exercise exercise) {
        return exerciseService.updateExercise(exercise);
    }
}
